!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("promote-analytics-adapter",[],t):"object"==typeof exports?exports["promote-analytics-adapter"]=t():n["promote-analytics-adapter"]=t()}("undefined"!=typeof self?self:this,function(){return function(n){var t={};function e(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=n,e.c=t,e.d=function(n,t,r){e.o(n,t)||Object.defineProperty(n,t,{enumerable:!0,get:r})},e.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},e.t=function(n,t){if(1&t&&(n=e(n)),8&t)return n;if(4&t&&"object"==typeof n&&n&&n.__esModule)return n;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:n}),2&t&&"string"!=typeof n)for(var o in n)e.d(r,o,function(t){return n[t]}.bind(null,o));return r},e.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return e.d(t,"a",t),t},e.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},e.p="https://static.parastorage.com/services/promote-analytics-adapter/2.364.0/",e.p="undefined"!=typeof window&&window.__STATICS_BASE_URL__||e.p,e(e.s=29)}({1:function(n,t,e){"use strict";var r=function(n,t){var e=Object.keys(n);return 0===e.length?n:e.reduce(function(e,r){var o=t[r];return o&&(n[r]||0===n[r])&&(e[o]=n[r]),e},{})},o=Object.assign||function(n){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}var c={id:"id",price:"value",value:"value",revenue:"value",name:"content_name",category:"content_category",currency:"currency",content_ids:"content_ids",contents:"contents",type:"content_type",num_items:"num_items",quantity:"quantity",label:"content_name"},a=function(n){var t=n.type,e=void 0===t?"product":t,o=i(n,["type"]),a=Object.assign({},o,{type:e});return a.contents&&(a.contents=a.contents.map(function(n){return n.quantity=n.quantity||1,n.item_price=n.item_price||n.price||0,n}),a.price||a.value||a.revenue||(a.price=function(n){return(Number.parseFloat(n.tax)||0)+(Number.parseFloat(n.shipping)||0)+n.contents.reduce(function(n,t){return n+Number.parseFloat(t.item_price)*t.quantity},0)}(a).toString()),a.currency||(a.currency=function(n){return n.contents&&n.contents[0].currency}(a))),r(a,c)},u=function(n){if(n.contents&&!n.num_items){var t=o({},n);return t.num_items=t.contents.reduce(function(n,t){return n+(t.quantity||1)},0),t}return n},s={ViewContent:function(n){var t=n.id,e=i(n,["id"]);return[["track","ViewContent",o({},a(e),{content_ids:[t],content_type:"product"})]]},AddToCart:function(n){var t=n.id,e=i(n,["id"]);return[["track","AddToCart",o({},a(e),{content_ids:[t],content_type:"product"})]]},InitiateCheckout:function(n){return[["track","InitiateCheckout",o({},a(u(n)),n.contents&&{content_ids:n.contents.map(function(n){return n.id}),content_type:"product"})]]},AddPaymentInfo:function(n){return[["track","AddPaymentInfo",o({},a(u(n)),n.contents&&{content_ids:n.contents.map(function(n){return n.id}),content_type:"product"})]]},Purchase:function(n){return[["track","Purchase",o({},a(u(n)),n.contents&&{content_ids:n.contents.map(function(n){return n.id}),content_type:"product"})]]},Lead:function(n){return[["track","Lead",r(n,c)]]},CustomEvent:function(n){var t=n.event,e=n.eventAction,r=void 0===e?"customEvent":e,o=i(n,["event","eventAction"]);return[["trackCustom",t||r,o]]}},d=Object.assign||function(n){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}(n,["event","eventAction"]);return"pageview"===e.toLowerCase()?[["send","pageview",r(i,p)]]:[["send","event",d({eventAction:o||e},i)]]}},l=Object.assign||function(n){for(var t=1;t=0||Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}var y={AddProductImpression:function(n){var t=n.contents,e=n.origin;return[[[l({event:"productImpression"},e&&{origin:e},{ecommerce:{impressions:t}})]]]},ClickProduct:function(n){var t=n.list,e=void 0===t?"(not set)":t,r=n.origin,o=m(n,["list","origin"]);return[[[l({event:"productClick"},r&&{origin:r},{ecommerce:{click:{actionField:{list:e},products:[o]}}})]]]},ViewContent:function(n){var t=n.list,e=void 0===t?"(not set)":t,r=n.origin,o=m(n,["list","origin"]);return[[[l({event:"viewContent"},r&&{origin:r},{ecommerce:{detail:{actionField:{list:e},products:[o]}}})]]]},AddToCart:function(n){var t=n.origin,e=m(n,["origin"]);return[[[l({event:"addToCart"},t&&{origin:t},{ecommerce:{add:{products:[e]}}})]]]},RemoveFromCart:function(n){var t=n.origin,e=m(n,["origin"]);return[[[l({event:"removeFromCart"},t&&{origin:t},{ecommerce:{remove:{products:[e]}}})]]]},InitiateCheckout:function(n){var t=n.contents,e=void 0===t?[]:t,r=n.origin,o=n.option,i=[].concat(e),c=Object.assign({},o&&{option:o});return[[[l({event:"checkout"},r&&{origin:r},{ecommerce:{checkout:{actionField:c,products:i}}})]]]},StartPayment:function(n){var t=n.origin;return[[[l({event:"checkoutOption"},t&&{origin:t},{ecommerce:{checkout_option:{actionField:{step:1}}}})]]]},AddPaymentInfo:function(n){var t=n.origin,e=n.option,r=Object.assign({step:2},e&&{option:e});return[[[l({event:"checkoutOption"},t&&{origin:t},{ecommerce:{checkout_option:{actionField:r}}})]]]},CheckoutStep:function(n){var t=n.step,e=void 0===t?3:t,r=n.origin,o=n.option,i=Object.assign({step:e},o&&{option:o});return[[[l({event:"checkoutOption"},r&&{origin:r},{ecommerce:{checkout_option:{actionField:i}}})]]]},Purchase:function(n){var t=n.contents,e=void 0===t?[]:t,r=n.origin,o=m(n,["contents","origin"]),i=[].concat(e),c={};return["id","affiliation","revenue","tax","shipping","coupon"].forEach(function(n){return o[n]&&(c[n]=o[n])}),[[[l({event:"purchase"},r&&{origin:r},{ecommerce:{purchase:{actionField:c,products:i}}})]]]},Lead:function(){return[[[{event:"lead"}]]]},CustomEvent:function(n){var t=n.event,e=void 0===t?"customEvent":t,r=m(n,["event"]);return[[[l({event:e},r)]]]}},g="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n};function h(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return"object"===(void 0===n?"undefined":g(n))&&(n instanceof Number||n instanceof Boolean||n instanceof String?n=n.valueOf():null!==n&&(n=JSON.stringify(n))),n}function A(n){return"number"==typeof n?Math.round(1e4*n):n}var _={PageView:{table:"page_views",paramsMap:{pageId:"page_id",pageNumber:"page_number"}},AddProductImpression:{},ClickProduct:{},ViewContent:{},AddToCart:{},RemoveFromCart:{},InitiateCheckout:{},AddPaymentInfo:{},Purchase:{},Lead:{name:function(n){return function(n){return n&&(""+n).replace(/\s/g,"")}(n.label)},table:"lead_events"}};function b(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments[4],i={evt:n,evn:t,data:function(n){return Object.keys(n).reduce(function(t,e){return t[e]=h(n[e]),t},{})}(e)};return r.context&&r.context.appDefId&&(i.appId=r.context.appDefId),o&&(i.tbl=o),[[i]]}var C=Object.keys(_).reduce(function(n,t){var e=_[t],r=e.name,o=e.table,i=e.paramsMap;return n[t]=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments[1];return"function"==typeof r&&(r=r(n)),i&&(n=Object.keys(i).reduce(function(t,e){return t[i[e]]=n[e],t},{})),function(n,t,e,r){return b("p",n,t,e,r)}(r=r||t,n,e,o)},n},{CustomEvent:function(n,t){var e=n.event,r=n.targetTable;return function(n,t,e,r){return b("c",n,t,e,r)}(e,function(n,t){var e={};for(var r in n)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}(n,["event","targetTable"]),t,r)}}),I=Object.assign||function(n){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=I({src:76},P[t].params,function(n,t){return n.reduce(function(n,e){var r=function(n,t,e){return"function"==typeof n[t]?n[t](e):{name:t,value:e}}(k,e,t[e]),o=r.name,i=r.value;return n[o]=h(i),n},{})}(P[t].fields,n));return e.context&&e.context.appDefId&&(r.appId=e.context.appDefId),[[r]]},n},{});var E={GA_TRACKING_ID:"GA_TRACKING_ID",pagePath:"page_path",pageTitle:"page_title"};!function(){for(var n=1;n<=200;n++)E["dimension"+n]="dimension"+n,E["metric"+n]="metric"+n}();var x,T,j={PageView:function(n,t){var e=t.config,o=n.GA_TRACKING_ID,i=function(n,t){var e={};for(var r in n)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}(n,["GA_TRACKING_ID"]);return[["config",o||e.trackingId,r(i,E)]]}},S=[],L={PageView:function(n){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).context;return t&&t.isFirstVisit?S:[[]]}},G={},N=void 0,R=void 0,D=function(n){return{isPremium:function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n.isPremium,e=n.isPremiumDomain,r=n.isPremiumUser;return t&&t()||e&&e()||r&&r()}(n),userId:n.getUserId(),metaSiteId:n.getMetaSiteId()}},V=function(n,t){(function(n,t){return Object.prototype.hasOwnProperty.call(n,t)})(G,n)||(G[n]=t)},F=function(n,t){Object.keys(G).forEach(function(e){G[e].call(void 0,n,function(n){return Object.assign({},n,R)}(t))})},q=function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};N&&N(n,t)};e.d(t,"a",function(){return M}),e.d(t,"b",function(){return Y}),e.d(t,"c",function(){return K});var M={FACEBOOK_PIXEL:"facebookPixel",GOOGLE_ANALYTICS:"googleAnalytics",GOOGLE_TAG_MANAGER:"googleTagManager",WIX_ANALYTICS:"wixAnalytics",BI_ANALYTICS:"biAnalytics",GTAG:"gtag",VK_RETARGETING:"vkRetargeting",YANDEX_METRICA:"yandexMetrica",WIX_DEVELOPERS_ANALYTICS:"wix-developers-analytics"},Y=((x={})[M.FACEBOOK_PIXEL]=s,x[M.GOOGLE_ANALYTICS]=v,x[M.GOOGLE_TAG_MANAGER]=y,x[M.WIX_ANALYTICS]=C,x[M.BI_ANALYTICS]=w,x[M.GTAG]=j,x[M.VK_RETARGETING]={PageView:function(){return[[]]}},x[M.YANDEX_METRICA]=L,x),K=((T={})[M.WIX_DEVELOPERS_ANALYTICS]=function(n,t){if(n){if(window){window.wixDevelopersAnalytics=window.wixDevelopersAnalytics||{register:V,triggerEvent:q},"function"==typeof window.onWixDevelopersAnalyticsReady&&window.onWixDevelopersAnalyticsReady();try{window.dispatchEvent(new Event("wixDevelopersAnalyticsReady"))}catch(n){}}return N=n,R=D(t),F}},T)},29:function(n,t,e){"use strict";e.r(t);var r=e(3);e.d(t,"api",function(){return r});var o=e(1);e.d(t,"channelNames",function(){return o.a}),e.d(t,"listeners",function(){return o.c})},3:function(n,t,e){"use strict";e.r(t);var r=function(n,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments[3],o=e.appDefId,i=function(n,t){var e={};for(var r in n)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);return e}(e,["appDefId"]);return t.events?((r=r||{}).config=t.config,r.context=r.context||{},"boolean"==typeof r.context&&(r.context={isFirstVisit:r.context}),r.context.appDefId=r.context.appDefId||o,t.events[n]?t.events[n](i,r):[]):[[n,i].concat(r?[r]:[])]},o=function(n,t,e,o){n.forEach(function(n){r(t,n,e,o).forEach(function(t){return n.report.apply(n,t)})})},i=e(1);var c=function(){function n(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(n,t){if(!(n instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),this._channels=[],this._listeners=[],this.addChannel=function(n){t.isChannelAlreadyInit(n)||(t.isChannelPredefined(n)?t.populateChannelEvents(n):t.registerChannel(n),t.isChannelValid(n)&&t._channels.push(n))},this.addListener=function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Array.isArray(n)&&n.forEach(function(n){if(t.isListenerInitializerValid(n)){var r=n(t.trackEvent,e);r&&t._listeners.push(r)}})},this.trackEvent=function(n,e,r){var i=t.getReporters();o(i,n,e,r)},this.getReporters=function(){var n=t._listeners.map(function(n){return{report:n}});return[].concat(n,t._channels)},this.isChannelAlreadyInit=function(n){return t._channels.some(function(t){return t.name===n.name})},this.isListenerInitializerValid=function(n){return n&&n instanceof Function},e.forEach(this.addChannel)}return n.prototype.isChannelPredefined=function(n){return i.b[n.name]},n.prototype.populateChannelEvents=function(n){n.events=i.b[n.name],n.events.publicTracking&&n.events.publicTracking instanceof Function&&n.events.publicTracking()},n.prototype.isChannelValid=function(n){var t=n.name,e=n.report,r=n.events&&Object.values(n.events).every(function(n){return"function"==typeof n});return t&&e&&r},n.prototype.registerChannel=function(n){this.isChannelValid(n)&&(i.b[n.name]=n.events)},n}();e.d(t,"init",function(){return u}),e.d(t,"addListener",function(){return s}),e.d(t,"trackEvent",function(){return d});var a=new c,u=function(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(a.addChannel)},s=function(n,t){a.addListener(n,t)},d=function(n,t,e){a.trackEvent(n,t,e)}}})}); //# sourceMappingURL=analytics-event-adapter.bundle.min.js.map